package com.sky.controller.user;


import com.sky.constant.StatusConstant;
import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(tags = "分类接口")
@Slf4j
@RequestMapping
@RestController("userCategoryController")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @ApiOperation("分类查询")
    @GetMapping("user/category/list")
    public Result<List<Category>> listByType(Integer type) {
        log.info("根据分类查询：查询{}",type );
        Category category = Category.builder()
                .type(type)
                .status(StatusConstant.ENABLE)
                .build();
        List<Category> list = categoryService.queryByType(category);
        return Result.success(list);
    }

}
